<?php

namespace app\adminmini\service;

use app\admin\model\Pay;
use think\facade\Db;

class PayService extends BaseService
{


    public function __construct()
    {
        $this->model = new Pay();
    }

    public function getUserInfo()
    {
        $info = Db::name('customer_store_match')->where('store_id', '=', $this->userId())->find();
        if ($info) {
            $result['wc_hid'] = $info['wc_hid'];
            $result['key'] = $info['key'];
        } else {
            $result['wc_hid'] = '';
            $result['key'] = '';
        }
        return message("操作成功", true, $result);
    }

    public function updateUserInfo()
    {
        // 参数
        $param = request()->param();
        // 个人信息
        $data = [
            'key' => $param['key'],
            'wc_hid' => $param['wc_hid'],
            'store_id' => $this->userId(),
        ];
        $result = $this->model->edit($data);
        if (!$result) {
            return message("更新资料信息失败", false);
        }
        return message("更新资料信息成功");
    }
}